package com.zpark.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @PackageName: com.zpark.controller
 * @ClassName: UserController
 * @Description:
 * @author: RZS
 * @date: 2023/4/10  14:57
 */
@Controller
@RequestMapping("/user")
public class UserController {

    /**
     * 演示转发
     * @return
     */
    @RequestMapping("/t1.do")
    public String t1(Model model){
        model.addAttribute("msg", "/t1.do");
        return "forward:/WEB-INF/pages/demo01.jsp";
    }

    @RequestMapping("/t2.do")
    public ModelAndView t2(){
        ModelAndView view = new ModelAndView();

        // 添加绑定数据
        view.addObject("user", "大锤");
        // 设置转发地址
        view.setViewName("forward:/WEB-INF/pages/demo02.jsp");

        return view;
    }

    @RequestMapping("/t4.do")
    public String t4(){
        // 转发到AddressController的t3方法
        return "forward:/add/t3.do";
    }
}
